<template>
  <div class="page-container">
    <el-header>
      <div style="box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);border-radius: 4px">
        <div style="height:150px;box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);border-radius: 4px;">
          <el-row>
            <el-col :span="24">
              <div class="grid-content bg-purple-light" style="text-align: left;">当前操作进度</div>
            </el-col>
            <el-col :span="24">
              <div class="grid-content">
                <el-steps align-center :space="1200" :active="active" finish-status="success">
                  <el-step title="1.导入合同商品"></el-step>
                  <el-step title="2.导入合同商品成功"></el-step>
                </el-steps>
                <el-button @click="nextStep">下一步</el-button>
              </div>
            </el-col>
          </el-row>
        </div>
      </div>
    </el-header>
    <el-main>
      <div
        style="box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);border-radius: 4px;display:block"
        id="pages"
      >
        <!--工具栏-->
        <div class="toolbar" style="padding-top:10px;padding-left:15px;">
          <el-form :inline="true" :model="filters" :size="size" ref="filters">
            
            <el-row class="search-input pd30">
               <el-form-item>
                <el-select v-model="filters.status" clearable placeholder="进项税率">
                  <el-option label="0%" value="1"></el-option>
                  <el-option label="3%" value="0"></el-option>
                  <el-option label="6%" value="1"></el-option>
                  <el-option label="9%" value="0"></el-option>
                  <el-option label="10%" value="1"></el-option>
                  <el-option label="11%" value="0"></el-option>
                  <el-option label="12.36%" value="1"></el-option>
                  <el-option label="13%" value="0"></el-option>
                  <el-option label="16%" value="1"></el-option>
                  <el-option label="17%" value="0"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item>
                <kt-button label="设置" type="primary" @click="set1" />
              </el-form-item>

              <el-form-item>
                <el-input
                  readonly
                  v-model="filters.number"
                  placeholder="含税采购价"
                  style="width: 200px;"
                ></el-input>
              </el-form-item>
              <el-form-item>
                <kt-button label="设置" type="primary" @click="set2" />
              </el-form-item>
            </el-row>
            <el-row class="search-button">
              <el-form-item>
                <kt-button label="按合同添加商品" type="primary" @click="addPro" />
              </el-form-item>

              <el-form-item>
                <kt-button label="批量删除" type="primary" @click="delCounts" />
              </el-form-item>    
            </el-row>
          </el-form>
        </div>
        <el-row class="t_r">
             <el-button-group>
                <el-tooltip content="刷新" placement="top">
                  <el-button icon="fa fa-refresh" @click="findPage(null)"></el-button>
                </el-tooltip>
                <el-tooltip content="列显示" placement="top">
                  <el-button icon="fa fa-filter" @click="displayFilterColumnsDialog"></el-button>
                </el-tooltip>
              </el-button-group>
        </el-row>
        <div class="toolbar" style="float:right;padding-top:10px;padding-right:15px;">
          <!-- <el-form :inline="true" :size="size">
            <el-form-item>
            </el-form-item>
          </el-form> -->
          <!--表格显示列界面-->
          <table-column-filter-dialog
            ref="tableColumnFilterDialog"
            :columns="columns"
            @handleFilterColumns="handleFilterColumns"
          ></table-column-filter-dialog>
        </div>
        <!--表格内容栏-->
        <cy-table
          :height="350"
          :data="pageResult"
          :columns="filterColumns"
          :showOperation="false"
          :showEditOperation="false"
          :showDeleteOperation="false"
          :showBatchDelete="false"
          @findPage="findPage"
          @selectionChange="selectionChange"
          ref="CyTable"
        ></cy-table>
      </div>
      <div style="display:none" id="test">
        <span style="font-size:larger">采购合同调价单生成成功！</span>
      </div>
    </el-main>

    <!--选择商家页面-->
    <el-dialog
      title="选择商家"
      width="40%"
      :visible.sync="editDialogVisible"
      :close-on-click-modal="false"
    >
      <el-form :model="dataFormMerchant" label-width="180px" ref="dataFormMerchant" :size="size">
        <el-row class="searchDialog-input">
           <el-form-item label="供应商编号：" prop="merchantCode">
          <el-input v-model="dataFormMerchant.merchantCode" auto-complete="off" placeholder="请输入"></el-input>
        </el-form-item>
        <el-form-item label="供应商名称：" prop="merchantName">
          <el-input v-model="dataFormMerchant.merchantName" auto-complete="off" placeholder="请输入"></el-input>
        </el-form-item>
        </el-row>

        <el-button :size="size" type="primary" :loading="editLoading">{{$t('action.submit')}}</el-button>
        <el-button
          :size="size"
          type="primary"
          @click.native="resetForm('dataFormMerchant')"
        >{{$t('action.reset')}}</el-button>
      </el-form>
      <el-table :data="tableData" style="width: 100%">
        <el-table-column prop="merchantCode" label="商家编码" width="150"></el-table-column>
        <el-table-column prop="merchantName" label="商家名称" width="150"></el-table-column>
        <el-table-column prop="merchantTypeName" label="商家类型"></el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button size="mini" @click="clickMerchant(scope.$index, scope.row)">选择此项</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>

    <!--选择合同商品-->
    <el-dialog
      title="选择合同商品"
      :visible.sync="proModel"
      width="45%"
      height="100%"
      label-width="80px"
      label-position="right"
    >
      <el-form style="text-align:left" label-width="110px" label-position="right">
        <el-row>
          <div>
            <el-form-item label="合同编码：" style="float:left;margin-left:90px">
              <el-input auto-complete="off" v-model="filter.contractCode" width="20%" size="mini" placeholder="请输入"></el-input>
            </el-form-item>

            <!-- <el-form-item label="店铺编码" style="float:left;margin-left:90px">
                <el-input auto-complete="off" width="20%" size="mini"></el-input>
            </el-form-item>-->
          </div>
        </el-row>

        <!-- <el-row>
            <div style="text-align:center">
              <el-form-item label="店铺名称" style="float:left;margin-left:90px">
                <el-input auto-complete="off" width="20% " size="mini"></el-input>
              </el-form-item>

              <el-form-item label="商品编码" style="float:left;margin-left:90px">
                <el-input auto-complete="off" width="20%" size="mini"></el-input>
              </el-form-item>
            </div>
        </el-row>-->

        <!-- <el-row>
            <div style="text-align:center">
              <el-form-item label="商品名称" style="float:left;margin-left:90px">
                <el-input auto-complete="off" width="20%" size="mini"></el-input>
              </el-form-item>

              <el-form-item label="结算地" style="float:left;margin-left:90px">
                <el-select placeholder="请选择" size="mini" style="width:178px">
                  <el-option label="平台" :value="0"></el-option>
                  <el-option label="门店" :value="1"></el-option>
                  <el-option label="商家" :value="2"></el-option>
                </el-select>
              </el-form-item>
            </div>
        </el-row>-->

        <div style="text-align:right">
          <el-form-item>
            <kt-button
              icon="fa fa-search"
              :label="$t('action.search')"
              type="primary"
              @click="findPage(null)"
            />
            <kt-button label="重置"  @click="resetForm" type="primary" />
          </el-form-item>
        </div>

        <el-table :data="proTables" border style="width: 100%" :visible.sync="proTable">
          <el-table-column prop="contractCode" label="合同编码"></el-table-column>
          <!-- <el-table-column prop="recivenumber" label="合同类型"></el-table-column> -->
          <el-table-column prop="ordertype" label="店铺名称"></el-table-column>
          <el-table-column prop="shopname" label="店铺编码"></el-table-column>
          <el-table-column prop="supplierName" label="供应商名称"></el-table-column>
          <el-table-column prop="supplierCode" label="供应商编码"></el-table-column>
          <el-table-column prop="productbarno" label="商品编码"></el-table-column>
          <el-table-column prop="productName" label="商品名称"></el-table-column>
          <!-- <el-table-column prop="shopname" label="主计量单位"></el-table-column> -->
          <el-table-column prop="productUnit" label="采购单位"></el-table-column>
          <el-table-column prop="transferRate" label="转换率"></el-table-column>
          <el-table-column prop="productSize" label="商品规格"></el-table-column>
          <el-table-column prop="originAmountWithTax" label="含税采购价"></el-table-column>
          <el-table-column prop="originTaxRate" label="进项税率"></el-table-column>
          <el-table-column prop="ordertype" label="流转途径"></el-table-column>
          <el-table-column prop="minNum" label="起订量"></el-table-column>
          <el-table-column prop="address" label="订货倍数"></el-table-column>
          <el-table-column prop="originTransportType" label="运输方式"></el-table-column>
          <el-table-column prop="originHasTransportPrice" label="是否含运费"></el-table-column>
          <!-- <el-table-column prop="create_time" label="库存组织进目录"></el-table-column>
          <el-table-column prop="create_time" label="库存量"></el-table-column>-->
        </el-table>
      </el-form>
      <div slot="footer" class="dialog-footer" style="text-align:right">
        <el-button @click="addOrder">生成采购单</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import PopupTreeInput from "@/components/PopupTreeInput";
import CyTable from "@/views/Core/CyTable";
import KtTable from "@/views/Core/KtTable";
import KtButton from "@/views/Core/KtButton";
import TableColumnFilterDialog from "@/views/Core/TableColumnFilterDialog";
import { format } from "@/utils/datetime";
import utils from "@/assets/js/utils.js";

export default {
  name: "ContractProductPriceStep1",

  components: {
    CyTable,
    KtButton,
    TableColumnFilterDialog
  },

  data() {
    return {
      filter: { contractCode: null },
      size: "small",
      filters: {
        merchantName: "",
        merchantId: "",

        res: {
          total: 1,
          code: "0000",
          rows: [
            {
              id: 1911290007105037,
              createTimeStr: null,
              contractCode: "HT1911290007105036",
              contractType: 2,
              contractTypeText: "代销合同",
              contractStatus: 2,
              contractStatusText: "已审核",
              supplierCode: "1911290006866570",
              supplierNames: "对账美元代销供应商",
              currencyCode: "USD",
              contractAmount: null,
              effectiveTime: 1574870400000,
              effectiveTimeStart: null,
              effectiveTimeEnd: null,
              expireTime: 1636473600000,
              expireTimeStart: null,
              expireTimeEnd: null,
              auditTime: null,
              auditTimeStart: null,
              auditTimeEnd: null,
              paymentPeriodId: 1909220000100060,
              paymentPeriodName: "代销对账",
              paymentPeriodType: 1,
              paymentPeriodTypeText: null,
              paymentPeriodDay: 0,
              settleRuleName: null,
              settlePeriodType: null,
              settlePeriodTypeText: null,
              settleExpireDay: null,
              turnoverChannel: null,
              isReturn: 1,
              isReturnText: null,
              remark: null,
              isPause: 0,
              isPauseText: "正常",
              isValid: 1,
              isValidText: "有效",
              isChange: 0,
              isChangeText: "正常合同",
              oldContractId: null,
              oldContractCode: null,
              contractChangeCode: null,
              contractChangeTime: null,
              merchantId: 1909110000098882,
              merchantCode: "001",
              merchantName: "张小二服饰",
              contractVersion: null,
              isDeleted: 0,
              versionNo: 0,
              companyId: 276,
              createUserid: 1909160000172983,
              createUsername: "merchant",
              createTime: 1575008759000,
              updateUserid: null,
              updateUsername: null,
              updateTime: 1575285210000,
              currentPage: null,
              itemsPerPage: null,
              performStatusText: "已审核",
              receivePort: null,
              tradeMethod: null,
              contractCategoryDTOS: [],
              contractContactDTO: null,
              feeTypeName: null,
              feeAmount: null,
              deductionRate: null,
              merchantProductId: null,
              merchantStoreId: null,
              merchantProductIds: null,
              merchantIds: null,
              storeIds: null,
              categoryCodes: null,
              notContractStatus: null,
              categoryCode: null,
              categoryName: null,
              contractCodeList: null,
              contractTypeList: null,
              mpIdList: null,
              paymentChannel: null,
              paymentMethod: "3",
              distributionChannel: null,
              deliveryMode: null,
              deliveryPort: null,
              invoiceType: 2,
              isForeignTrade: 0,
              foreignTradeShow: null,
              purchaseType: null,
              changeUserType: null,
              changeReason: null,
              changeUserTypeStr: null,
              contractProperty: "3",
              contractPropertyText: "自采合同",
              contractCategoryNames: null
            }
          ]
        }
      },
      columns: [
        { prop: "contractCode", label: "店铺编码", minWidth: 80 },
        { prop: "contractTypeText", label: "店铺名称", minWidth: 60 },
        { prop: "contractPropertyText", label: "供应商编码", minWidth: 60 },
        { prop: "isValidText", label: "供应商名称", minWidth: 60 },
        { prop: "supplierCode", label: "合同编码", minWidth: 120 },
        { prop: "supplierNames", label: "商品编码", minWidth: 70 },
        { prop: "merchantName", label: "商品条码", minWidth: 60 },
        { prop: "currencyCode", label: "商品名称", minWidth: 60 },
        { prop: "effectiveTime", label: "商品规格", minWidth: 80 },
        { prop: "expireTime", label: "主计量单位", minWidth: 80 },
        { prop: "supplierNamess", label: "采购单位", minWidth: 70 },
        { prop: "merchantName", label: "转换率", minWidth: 60 },
        { prop: "currencyCode", label: "交易币别", minWidth: 60 },
        { prop: "effectiveTime", label: "税率(%)", minWidth: 80 },
        { prop: "expireTime", label: "含税采购价", minWidth: 80 },
        { prop: "contractPropertyText", label: "未税采购价", minWidth: 60 },
        { prop: "isValidText", label: "起订量", minWidth: 60 },
        { prop: "supplierCode", label: "限定量", minWidth: 120 },
        { prop: "supplierName_s", label: "运输方式", minWidth: 70 },
        { prop: "merchantName", label: "是否含运费", minWidth: 60 },
        { prop: "currencyCode", label: "(原)税率(%)", minWidth: 60 },
        { prop: "effectiveTime", label: "(原)未税采购价", minWidth: 80 },
        { prop: "expireTime", label: "(原)含税采购价", minWidth: 80 },
        { prop: "supplierName_ss", label: "(原)起订量", minWidth: 70 },
        { prop: "merchantName", label: "(原)限定量", minWidth: 60 },
        { prop: "currencyCode", label: "(原)运输方式", minWidth: 60 },
        { prop: "effectiveTime", label: "(原)是否含运费", minWidth: 80 }
      ],

      tableData: [
        {
          currentPage: 0,
          itemsPerPage: 0,
          id: null,
          merchantId: 1910100000066478,
          merchantCode: "300001",
          merchantCodes: null,
          merchantName: "录屏商家02",
          merchantType: 11,
          merchantTypeName: "自营商家",
          isDefault: null,
          userId: null,
          status: null,
          merchantIds: null,
          isAvailable: null,
          isDeleted: null,
          versionNo: null,
          createUserid: null,
          createUsername: null,
          createUserip: null,
          createUsermac: null,
          createTime: null,
          createTimeDb: null,
          serverIp: null,
          updateUserid: null,
          updateUsername: null,
          updateUserip: null,
          updateUsermac: null,
          updateTime: null,
          updateTimeDb: null,
          clientVersionno: null,
          companyId: null,
          userName: null,
          startItem: 0
        },
        {
          currentPage: 0,
          itemsPerPage: 0,
          id: null,
          merchantId: 1910100000065618,
          merchantCode: "30001",
          merchantCodes: null,
          merchantName: "录屏商家01",
          merchantType: 11,
          merchantTypeName: "自营商家",
          isDefault: null,
          userId: null,
          status: null,
          merchantIds: null,
          isAvailable: null,
          isDeleted: null,
          versionNo: null,
          createUserid: null,
          createUsername: null,
          createUserip: null,
          createUsermac: null,
          createTime: null,
          createTimeDb: null,
          serverIp: null,
          updateUserid: null,
          updateUsername: null,
          updateUserip: null,
          updateUsermac: null,
          updateTime: null,
          updateTimeDb: null,
          clientVersionno: null,
          companyId: null,
          userName: null,
          startItem: 0
        },
        {
          currentPage: 0,
          itemsPerPage: 0,
          id: null,
          merchantId: 1910100000065171,
          merchantCode: "20001",
          merchantCodes: null,
          merchantName: "商家01",
          merchantType: 11,
          merchantTypeName: "自营商家",
          isDefault: null,
          userId: null,
          status: null,
          merchantIds: null,
          isAvailable: null,
          isDeleted: null,
          versionNo: null,
          createUserid: null,
          createUsername: null,
          createUserip: null,
          createUsermac: null,
          createTime: null,
          createTimeDb: null,
          serverIp: null,
          updateUserid: null,
          updateUsername: null,
          updateUserip: null,
          updateUsermac: null,
          updateTime: null,
          updateTimeDb: null,
          clientVersionno: null,
          companyId: null,
          userName: null,
          startItem: 0
        },
        {
          currentPage: 0,
          itemsPerPage: 0,
          id: null,
          merchantId: 1910100000063331,
          merchantCode: "009888",
          merchantCodes: null,
          merchantName: "测试商家shan古",
          merchantType: 11,
          merchantTypeName: "自营商家",
          isDefault: null,
          userId: null,
          status: null,
          merchantIds: null,
          isAvailable: null,
          isDeleted: null,
          versionNo: null,
          createUserid: null,
          createUsername: null,
          createUserip: null,
          createUsermac: null,
          createTime: null,
          createTimeDb: null,
          serverIp: null,
          updateUserid: null,
          updateUsername: null,
          updateUserip: null,
          updateUsermac: null,
          updateTime: null,
          updateTimeDb: null,
          clientVersionno: null,
          companyId: null,
          userName: null,
          startItem: 0
        },
        {
          currentPage: 0,
          itemsPerPage: 0,
          id: null,
          merchantId: 1910080000131175,
          merchantCode: "002",
          merchantCodes: null,
          merchantName: "育学园-测试",
          merchantType: 11,
          merchantTypeName: "自营商家",
          isDefault: null,
          userId: null,
          status: null,
          merchantIds: null,
          isAvailable: null,
          isDeleted: null,
          versionNo: null,
          createUserid: null,
          createUsername: null,
          createUserip: null,
          createUsermac: null,
          createTime: null,
          createTimeDb: null,
          serverIp: null,
          updateUserid: null,
          updateUsername: null,
          updateUserip: null,
          updateUsermac: null,
          updateTime: null,
          updateTimeDb: null,
          clientVersionno: null,
          companyId: null,
          userName: null,
          startItem: 0
        },
        {
          currentPage: 0,
          itemsPerPage: 0,
          id: null,
          merchantId: 1909190000580354,
          merchantCode: "1901",
          merchantCodes: null,
          merchantName: "test001",
          merchantType: 11,
          merchantTypeName: "自营商家",
          isDefault: null,
          userId: null,
          status: null,
          merchantIds: null,
          isAvailable: null,
          isDeleted: null,
          versionNo: null,
          createUserid: null,
          createUsername: null,
          createUserip: null,
          createUsermac: null,
          createTime: null,
          createTimeDb: null,
          serverIp: null,
          updateUserid: null,
          updateUsername: null,
          updateUserip: null,
          updateUsermac: null,
          updateTime: null,
          updateTimeDb: null,
          clientVersionno: null,
          companyId: null,
          userName: null,
          startItem: 0
        },
        {
          currentPage: 0,
          itemsPerPage: 0,
          id: null,
          merchantId: 1909190000034117,
          merchantCode: "yxy03",
          merchantCodes: null,
          merchantName: "育学园-商城",
          merchantType: 11,
          merchantTypeName: "自营商家",
          isDefault: null,
          userId: null,
          status: null,
          merchantIds: null,
          isAvailable: null,
          isDeleted: null,
          versionNo: null,
          createUserid: null,
          createUsername: null,
          createUserip: null,
          createUsermac: null,
          createTime: null,
          createTimeDb: null,
          serverIp: null,
          updateUserid: null,
          updateUsername: null,
          updateUserip: null,
          updateUsermac: null,
          updateTime: null,
          updateTimeDb: null,
          clientVersionno: null,
          companyId: null,
          userName: null,
          startItem: 0
        },
        {
          currentPage: 0,
          itemsPerPage: 0,
          id: null,
          merchantId: 1909190000034086,
          merchantCode: "yxy02",
          merchantCodes: null,
          merchantName: "育学园-教育",
          merchantType: 11,
          merchantTypeName: "自营商家",
          isDefault: null,
          userId: null,
          status: null,
          merchantIds: null,
          isAvailable: null,
          isDeleted: null,
          versionNo: null,
          createUserid: null,
          createUsername: null,
          createUserip: null,
          createUsermac: null,
          createTime: null,
          createTimeDb: null,
          serverIp: null,
          updateUserid: null,
          updateUsername: null,
          updateUserip: null,
          updateUsermac: null,
          updateTime: null,
          updateTimeDb: null,
          clientVersionno: null,
          companyId: null,
          userName: null,
          startItem: 0
        },
        {
          currentPage: 0,
          itemsPerPage: 0,
          id: null,
          merchantId: 1909190000034080,
          merchantCode: "yxy01",
          merchantCodes: null,
          merchantName: "育学园-会员",
          merchantType: 12,
          merchantTypeName: "入驻商家",
          isDefault: null,
          userId: null,
          status: null,
          merchantIds: null,
          isAvailable: null,
          isDeleted: null,
          versionNo: null,
          createUserid: null,
          createUsername: null,
          createUserip: null,
          createUsermac: null,
          createTime: null,
          createTimeDb: null,
          serverIp: null,
          updateUserid: null,
          updateUsername: null,
          updateUserip: null,
          updateUsermac: null,
          updateTime: null,
          updateTimeDb: null,
          clientVersionno: null,
          companyId: null,
          userName: null,
          startItem: 0
        },
        {
          currentPage: 0,
          itemsPerPage: 0,
          id: null,
          merchantId: 1909110000098882,
          merchantCode: "001",
          merchantCodes: null,
          merchantName: "张小二服饰",
          merchantType: 11,
          merchantTypeName: "自营商家",
          isDefault: null,
          userId: null,
          status: null,
          merchantIds: null,
          isAvailable: null,
          isDeleted: null,
          versionNo: null,
          createUserid: null,
          createUsername: null,
          createUserip: null,
          createUsermac: null,
          createTime: null,
          createTimeDb: null,
          serverIp: null,
          updateUserid: null,
          updateUsername: null,
          updateUserip: null,
          updateUsermac: null,
          updateTime: null,
          updateTimeDb: null,
          clientVersionno: null,
          companyId: null,
          userName: null,
          startItem: 0
        }
      ],
      //合同table
      proTables: [],

      filterColumns: [],
      pageRequest: { pageNum: 1, pageSize: 10 },
      pageResult: {},
      proModel: false,
      proTable: false,
      editLoading: false,
      pageShow: false, //默认页面显示
      active: 0,
      editDialogVisible: false, // 新增编辑界面是否显示
      dataFormMerchant: {
        merchantCode: "",
        merchantName: ""
      }
    };
  },

  methods: {
    queryMerchantList: function() {
      this.editDialogVisible = true;
    },

    // 根据合同编码获得对应商品信息
    findPage: function(data) {
      if (this.filter.contractCode == null) {
        this.$message({
          message: '请输入合同编号！',
          type: 'warning'
        });
        return
      }
      let this_ = this;
      // this.$refs.CyTable.findPageStaticState(this.filters);
      this.utils.request.findPurchaseContractProduct(this.filter, function(
        res
      ) {
        this_.proTables = res.data;
      });
    },

    // 处理表格列过滤显示
    displayFilterColumnsDialog: function() {
      this.$refs.tableColumnFilterDialog.setDialogVisible(true);
    },

    // 处理表格列过滤显示
    handleFilterColumns: function(data) {
      this.filterColumns = data.filterColumns;
      this.$refs.tableColumnFilterDialog.setDialogVisible(false);
    },

    // 处理表格列过滤显示
    initColumns: function() {
      let temp = [];

      $.each(this.columns, function(key, val) {
        temp.push(val);
      });
      this.filterColumns = temp;
    },

    nextStep: function() {
      var this_ = this;
      if (this_.active++ > 1) {
        this_.active = 0;
      }
      document.getElementById("pages").style.display = "none";
      document.getElementById("test").style.display = "block";
    },

    resetForm(formName) {
        this.filter.contractCode=null;
    },

    clickMerchant: function(index, row) {
      let this_ = this;
      console.log("tttttt");
      console.log(index, row);
      this_.filters.merchantName = row.merchantName;
      this_.filters.merchantId = row.merchantId;
      this_.editDialogVisible = false;
    },

    //选择框
    selectionChange: function(params) {
      this.checked = params.selections;
    },
    // 批量删除
    handleDelete: function(data) {
      if (data != null && data.params != null && data.params.length > 0) {
        let ids = data.params.map(item => item.id).toString();

        var params = {};
        params.t = "changeProduct";
        params.ids = ids;
        var this_ = this;
        this.utils.request.deleteUserInfo(params, function(res) {
          if (res.code == "0000") {
            this_.$message({ message: "操作成功", type: "success" });
            this_.findPage(null);
          } else {
            this_.$message({ message: "操作失败, " + res.msg, type: "error" });
          }
        });
      }
    },
    //批量删除
    delCounts() {
      this.$message({ message: "操作成功 ", type: "success" });
    },
    set1() {
      this.$message({ message: "设置成功 ", type: "success" });
    },
    set2() {
      this.$message({ message: "设置成功", type: "success" });
    },
    closePro() {
      (this.proModel = false), (this.proTable = false);
    },
    //根据合同生成对应采购单
    addOrder() {
      (this.proModel = false), (this.proTable = false);
      //判断合同内商品数据是否为空
      if(this.proTables.length>0){
        alert(this.proTables[0].contractCode)
      this.utils.request.generatePurchaseOrder(params, function(res) {
      });
      }
    },
    set1() {
      this.$message({ message: "设置成功 ", type: "success" });
    },
    set2() {
      this.$message({ message: "设置成功", type: "success" });
    },
    closePro() {
      (this.proModel = false), (this.proTable = false);
    },
    //根据合同生成对应采购单
    addOrder() {
      let this_ = this;
      (this.proModel = false), (this.proTable = false);
      //判断合同内商品数据是否为空
      if(this.proTables.length>0){
      this.utils.request.generatePurchaseOrder({contractNo:this.proTables[0].contractCode}, function(res) {
          if (res.code == "0000") {
            this_.$message({ message: "操作成功", type: "success" });
            this_.findPage(null);
          } else {
            this_.$message({ message: "操作失败, " + res.msg, type: "error" });
          }
        });


      }else{
        this.$message({
          message: '合同内商品数据不能为空！',
          type: 'error'
        });
      }
    },
    addPro() {
      (this.proModel = true), (this.proTable = true);
    }
  },
  mounted() {
    this.initColumns();
  }
};
</script>

<style scoped lang='scss'>
/deep/ .form .el-input__inner {
  width: 200px !important;
}
.pd30{
  padding-top: 30px;
}
</style>
